//不要给我WA WA 叫
//一定AC
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <iomanip>
#include <climits>
#define int long long 
#define x first 
#define y second 
using namespace std;
const int N = 1e5 + 10;
int a[N];
void solve()
{
    string s;
    cin >> s;
    int f = 0;
    int pos = 0;
    for(int i = 0; i < s.size(); i++)
    {
        if(s[i] == '@') 
        {
            pos = i;
            f = 1;
            break;
        } 
    }
    if(!f || pos == 0 || pos == s.size() - 1) 
    {
        cout << "No" << endl;
        return;
    }
    string s1 = s.substr(0,pos);
    //cout << s1 << endl;
    string s2 = s.substr(pos + 1 , s.size() - pos + 1);
    //cout << s2 << endl;
    if(s1.size() > 64 || s1.size() < 1 || s2.size() > 255 || s2.size() < 1) 
    {
        cout << "No" << endl;
        return;
    }
    if(s1[0] == '.' || s1[s1.size() - 1] == '.' || s2[0] == '.' || s2[s2.size() - 1] == '.' || s2[0] == '-' || s2[s2.size() - 1] == '-')
    {
        cout << "No" << endl;
        return;
    }
    for(int i = 0; i < s1.size(); i++)
    {
        if(!isdigit(s1[i]) && !isalpha(s1[i]) && s1[i] != '.')
        {
            cout << "No" << endl;
            return;
        }
    }
     for(int i = 0; i < s2.size(); i++)
    {
        if(!isdigit(s2[i]) && !isalpha(s2[i]) && s2[i] != '.' && s2[i] != '-')
        {
            cout << "No" << endl;
            return;
        }
    }
    cout << "Yes" << endl;
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr),cout.tie(nullptr);
    int t;
    cin >> t;
    while(t -- )  solve();
    return 0;
}
